<template>
  <div class="container">
    <normal-title title="通知"></normal-title>
    <div class="main">
      <img
        class="logo"
        src="../../images/logo_lg.png"
        mode="aspectFit"
      >
      <div>
        <div class="user">{{real_name}}</div>
        <div class='invitation'>邀请您成为<span class="yStore">{{team_name}}</span>团队成员</div>
      </div>
      <form
        :report-submit="true"
        @submit="formSubmit"
      >
        <radio-group
          name='status'
          class="radio-group row between"
          @change="radioChange"
        >
          <label
            class="radio"
            v-for="(item,index) in items"
            :key="index"
          >
            <radio
              color='#d0b47f'
              :value="item.value"
              :checked="item.checked"
            />{{item.name}}
          </label>
        </radio-group>
        <button
          form-type="submit"
          class="btn sel"
        >确定</button>
        <!-- <button class="btn">拒绝</button> -->
      </form>
    </div>
    <img
      class="bg"
      src="../../images/login_bg_1.png"
      mode="widthFix"
    >
  </div>
</template>

<script>
import NormalTitle from "@/components/NormalTitle";
import { request } from "@/utils";
import { setTimeout } from "timers";
export default {
  components: {
    NormalTitle
  },
  data() {
    return {
      items: [
        { name: "同意", value: 2, checked: "true" },
        { name: "拒绝", value: 3 }
      ],
      team_name: "",
      real_name: ""
    };
  },
  methods: {
    async formSubmit(e) {
      var formData = e.mp.detail;
      var adminUserId = this.$root.$mp.query.admin_user_id || 0;
      var data = {
        form_id: formData.formId,
        status: formData.value.status,
        admin_user_id: adminUserId
      };
      var res = await request(
        "/v1/personal-center/confirm-to-join",
        "post",
        data
      );
      if (res.data.success) {
        wx.showToast({
          title: res.data.message,
          icon: "none"
        });
        setTimeout(() => {
           wx.switchTab({
            url: "/pages/mine/main"
          });
        }, 1500);
      }else{
        wx.showToast({
          title: res.data.message,
          icon: "none"
        });
      }
    }
  },
  mounted() {
    this.team_name = this.$root.$mp.query.team_name;
    this.real_name = this.$root.$mp.query.real_name;
  }
};
</script>

<style>
page {
  height: 100%;
}
</style>

<style scoped lang="scss">
.container {
  button {
    border: none;
    background-color: transparent;
    box-sizing: border-box;
  }
  button::after {
    border: none;
  }
  .main {
    font-size: 20px;
    display: flex;
    justify-content: space-between;
    flex-direction: column;
    align-items: center;
    height: 550rpx;
    margin-top: 50rpx;
    .logo {
      height: 80rpx;
    }
    .user {
      font-size: 24px;
      text-align: center;
    }
    .invitation {
      margin-top: 20rpx;
      .yStore {
        color: #d0b47f;
      }
    }
    .radio-group {
      font-size: 16px;
      width: 300rpx;
      height: 100rpx;
    }
    .btn {
      margin-top: 25rpx;
      width: 300rpx;
      height: 70rpx;
      line-height: 68rpx;
      border-radius: 35rpx;
      color: #d0b47f;
      border: 2rpx solid #d0b47f;
      font-size: 32rpx;
      padding: 0;
    }
    .sel {
      background: #d0b47f;
      color: #fff;
    }
  }
  .bg {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 750rpx;
  }
}
</style>




